php multi type parameter php multi type parameter

145

php multi type parameter php multi type parameter -

#Union types have finally been implemented in PHP 8.0
class Number {
    private int|float $number;

    public function setNumber(int|float $number): void {
        $this->number = $number;
    }

    public function getNumber(): int|float {
        return $this->number;
    }
}

Comments

Submit
0 Comments